home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / other / flexcat / lib / autoc_c.sd < prev    next >
Text File  |  1999-06-14  |  3KB  |  120 lines

  1. ##stringtype C
  2. ##shortstrings
  3. /****************************************************************
  4.    This file was created automatically by `%fv'
  5.    from "%f0".
  6.  
  7.    Do NOT edit by hand!
  8. ****************************************************************/
  9.  
  10. /****************************************************************
  11.     This file uses the auto initialization possibilities of
  12.     Dice, gcc and SAS/C, respectively.
  13.  
  14.     Dice does this by using the keywords __autoinit and
  15.     __autoexit, SAS uses names beginning with _STI or
  16.     _STD, respectively. gcc uses the asm() instruction,
  17.     to emulate C++ constructors and destructors.
  18.  
  19.     Using this file you don't have *all* possibilities of
  20.     the locale.library. (No Locale or Language arguments are
  21.     supported when opening the catalog. However, these are
  22.     *very* rarely used, so this should be sufficient for most
  23.     applications.
  24.  
  25.     If you really need all possibilities or you have another
  26.     compiler, you should use the source description C_c_V21.sd
  27.     instead.
  28. ****************************************************************/
  29.  
  30.  
  31. /*
  32.     Include files and compiler specific stuff
  33. */
  34. #include <libraries/locale.h>
  35.  
  36. #if defined(__SASC)  ||  defined(_DCC)
  37. #include <proto/exec.h>
  38. #include <proto/locale.h>
  39. typedef struct Library LocaleBase_t;
  40. #elif defined(__GNUC__)
  41. #include <inline/exec.h>
  42. #include <inline/locale.h>
  43. typedef struct LocaleBase LocaleBase_t;
  44. #else
  45. #error "Don't know how to handle your compiler."
  46. #endif
  47.  
  48. #if defined(__SASC) || defined(__GNUC__)
  49. #define __autoinit
  50. #define __autoexit
  51. #endif
  52.  
  53.  
  54. /*
  55.     Variables
  56. */
  57. struct FC_Type
  58. {   LONG   ID;
  59.     STRPTR Str;
  60. };
  61. const struct FC_Type _%i = { %d, (STRPTR) %s };
  62.  
  63. static struct Catalog *%b_Catalog = NULL;
  64.  
  65. LocaleBase_t *LocaleBase;
  66.  
  67.  
  68.  
  69.  
  70.  
  71. STATIC __autoinit VOID _STIOpenCatalog(VOID)
  72.  
  73.   {
  74.     STATIC const struct TagItem tags[] =
  75.       {
  76.     { OC_BuiltInLanguage, (ULONG) %l },
  77.     { OC_Version, %v },
  78.     { TAG_DONE, 0 }
  79.       };
  80.     if ((LocaleBase = (LocaleBase_t *)
  81.               OpenLibrary((STRPTR) "locale.library", 38)))
  82.     {
  83.       %b_Catalog = OpenCatalogA(NULL, (STRPTR) "%b.catalog",
  84.                 (struct TagItem *) tags);
  85.     }
  86.   }
  87.  
  88.  
  89.  
  90. STATIC __autoexit VOID _STDCloseCatalog(VOID)
  91.  
  92.   {
  93.     if (LocaleBase)
  94.       {
  95.     CloseCatalog(%b_Catalog);
  96.     %b_Catalog = NULL;
  97.     CloseLibrary((struct Library *) LocaleBase);
  98.       }
  99.   }
  100.  
  101.  
  102.  
  103. STRPTR GetString(struct FC_Type *fcstr)
  104.  
  105.   {
  106.     STRPTR defaultstr;
  107.     LONG strnum;
  108.  
  109.     strnum = fcstr->ID;
  110.     defaultstr = fcstr->Str;
  111.  
  112.     return(%b_Catalog ? GetCatalogStr(%b_Catalog, strnum, defaultstr) :
  113.             defaultstr);
  114.   }
  115.  
  116. #if defined(__GNUC__)
  117. asm ("  .text;  .stabs \\\"___CTOR_LIST__\\\",22,0,0,__STIOpenCatalog");
  118. asm ("  .text;  .stabs \\\"___DTOR_LIST__\\\",22,0,0,__STDCloseCatalog");
  119. #endif
  120.